package com.sky.factory;

import java.util.Objects;
import java.util.Scanner;

/**
 * Created by Frank Lau on 2017/5/26 0026.
 */
public class calculator_1_3 {
    //client-end
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("請輸入數字A: ");
        String A = scanner.nextLine();
        System.out.println("請輸入運算符(+ - * /): ");
        String B = scanner.nextLine();
        System.out.println("請輸入數字B: ");
        String C = scanner.nextLine();

        String D;
        if (!Objects.equals(A, "") && !Objects.equals(B, "")) {
            D = String.valueOf(OperationFactory.createOperate(B).getResult(Double.parseDouble(A), Double.parseDouble(C)));
            System.out.print(D);
        }
        else {
            System.out.print("輸入有誤, 請重新輸入.");
        }

    }
}
